#coding:utf-8
import os
import time
from common.MngApiData import MngApiData

__author__ = 'yangxianming'

import json
import requests


def core_login():
    mng_api_data = MngApiData()

    core_headers = {
        "Content-Type":"application/json;charset=UTF-8",
        "Accept":"application/json, text/plain, */*"
    }
    url = "https://fywmngdev.e-fuli.com/mngWeb/mng"
    p = mng_api_data.efuli_login_admin_data()
    r = requests.post(url, json.dumps(p), headers=core_headers)
    cookie = r.headers["Set-Cookie"]
    print(cookie)
    jsessionid = cookie[11:43]
    print("jsessionid:" + jsessionid)
    return jsessionid


def corp_login():
    mng_api_data = MngApiData()

    core_headers = {
        "Content-Type":"text/plain;charset=UTF-8",
        "Accept":"application/json, text/plain, */*"
    }
    url = "https://fywmngdev.e-fuli.com/mngWeb/mng"
    p = mng_api_data.efuli_login_real_data()
    r = requests.post(url, json.dumps(p), headers=core_headers)
    print(r.json())
    cookie = r.headers["Set-Cookie"]
    print(cookie)
    jsessionid = cookie[11:43]
    print("jsessionid:" + jsessionid)
    return jsessionid

def test():
    t = str(int(round(time.time() * 1000)))
    print(t)
    print(t[9:13])

# test()